const {dialog,MenuItem,app,shell} = require('electron')
const Path = require('path');
const OS = require('os');
const fs = require('fs');
const DataStore = require('../../app-store');
const dataStore = new DataStore();
const appLogin = require('../../cookie/app-login');
const extensionFile = Path.join(OS.homedir(), app.name, 'extensions.json');

exports.menu = function (menu, tray) {
    // 注册快捷键
    const params = fs.readFileSync(extensionFile, "utf8")
    for (const param of JSON.parse(params)) {
        menu.append( new MenuItem({
            label: param.label,
            click: function(){
                appLogin.getSiteCookie(param.url, (cookie) => {}, param.label)
            }
        }))
    }
    tray.setTitle('插件')
}
